package com.yz.lzq.liwushuo.ui.logo;

import android.content.Context;
import android.os.Handler;

import com.yz.lzq.liwushuo.ui.modules.comminterface.OnGetSharedPerfenceDataListener;
import com.yz.lzq.liwushuo.ui.modules.comminterface.OnGoToNetActivityListener;
import com.yz.lzq.liwushuo.ui.setting.SettingActivityPresenter;

/**
 * Created by Administrator on 2016/12/3.
 * LogoActivity  要向下一个页面跳转时的  Presenter类
 */

public class LogoActivityPresenter implements OnGoToNetActivityListener {
    //view层的接口
    private LogoContract.LogoActivityViewInterface viewInterface;
    //model层的接口
    private LogoContract.LogoActivityModelInterface modelInterface;
    //获取SettingActivity中间人的对象
    private SettingActivityPresenter presenter = null;
    private Context mContext = null;

    public LogoActivityPresenter(Context mContext, LogoContract.LogoActivityViewInterface viewInterface) {
        this.viewInterface = viewInterface;
        this.modelInterface = new LogoActivityModel();
        this.mContext = mContext;
        presenter = new SettingActivityPresenter(mContext);
    }

    private Handler handler = new Handler() {
    };

    public void jumpActivity() {

        modelInterface.SleepThread(this);
    }

    @Override
    public void goToNextActivity() {
        presenter.setOnGetUserSharedPerfence(new OnGetSharedPerfenceDataListener() {
            @Override
            public void onGetGenderAndGenration(int gender, int genration) {
                if (99 == gender && 99 == genration) {
                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            viewInterface.gotoSettingActivity();
                        }
                    });
                } else {
                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            viewInterface.gotoMainActivity();
                        }
                    });
                }
            }
        });

    }
}
